<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test2</title>
</head>

<body>
<h4>这是一个js学习网页</h4>
<p id="p1"></p>
<button onclick="Json()">JSON</button>
<p id="p2"></p>
<p id="p3"></p>

<script>
    //JSON是一种特定格式（js特供）的文本（txt）
    let text = '{"employees":[' +
        '{"firstName":"Bill","lastName":"Gates" },' +
        '{"firstName":"Steve","lastName":"Jobs" },' +
        '{"firstName":"Elon","lastName":"Musk" }]}';
    obj = JSON.parse(text);
    function Json() {
        document.getElementById("p1").innerHTML =
            obj.employees[1].firstName + " " + obj.employees[1].lastName;
    }

</script>



</body>

</html>